local extension = Package:new("yinbiao")
extension.extensionName = "king"
local U = require "packages/utility/utility"

Fk:loadTranslationTable{
  ["yinbiao"] = "阴-标",
}





local yin__xusheng = General(extension, "moudabao", "wu", 4)

  local yinxianshou = fk.CreateTriggerSkill{
  name = "yinxianshou",
  events = {fk.EventPhaseStart},
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player ~= target and target.phase == Player.Start 
  end,

  on_cost = function(self, event, target, player, data)
    local room = player.room
    local choices = {"Cancel", "yinxianshou_discard"}
    local choice = room:askForChoice(player, choices, self.name, "#yinxianshou-choice::" .. target.id, false,
    {"yinxianshou_discard", "Cancel"})
    if choice == "Cancel" then return false end
    room:doIndicate(player.id, {target.id})
    self.cost_data = choice
    return true
  end,

  on_use = function(self, event, target, player, data)
    local room = player.room
      player:broadcastSkillInvoke(self.name)
      room:notifySkillInvoked(player, self.name, "offensive")
      if not target:isNude() then
        local card = room:askForCardChosen(player, target, "he", self.name)
        room:throwCard({card}, self.name, target, player)
        if player.dead or target.dead then return false end
      end
      room:useVirtualCard("slash", nil, player, target, self.name, true)
  end,
  }
  local fengsuo = fk.CreateTriggerSkill{
  name = "fengsuo",
  anim_type = "offensive",
  events = {fk.TargetSpecified},
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.to ~= player.id and
      data.card.trueName == "slash"
  end,

  on_use = function(self, event, target, player, data)
    local room = player.room
    room:notifySkillInvoked(player, self.name)
    player:broadcastSkillInvoke(self.name, 1)
    local to = room:getPlayerById(data.to)
    data.disresponsive = true
    room:addPlayerMark(to, "@@fengsuo-turn")
    room:addPlayerMark(to, MarkEnum.UncompulsoryInvalidity .. "-turn")

    local choices = {"fengsuo-zhiqu", "fengsuo-chuzheng"}
    local choice = room:askForChoice(player, choices, self.name, "#fengsuo-choice::" .. target.id, false,
    {"fengsuo-zhiqu", "fengsuo-chuzheng"})
    if choice == "fengsuo-zhiqu" then
      local card = room:askForCardChosen(player, to, "he", self.name)
      room:obtainCard(player, card, false, fk.ReasonPrey)
    elseif choice == "fengsuo-chuzheng" then
      player:drawCards(2, self.name)
    end
  end,
  }
  local mpj = fk.CreateTriggerSkill{
  name = "mpj",
  anim_type = "offensive",
  events = {fk.TargetSpecified, fk.DamageCaused},
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) and data.card and data.card.trueName == "slash" then
      if event == fk.TargetSpecified then
        local to = player.room:getPlayerById(data.to)
        return not to.dead and to.hp > 0 and not to:isNude()
      elseif event == fk.DamageCaused then
        return player.room.logic:damageByCardEffect()
        and player:getHandcardNum() >= data.to:getHandcardNum() and
        #player:getCardIds(Player.Equip) >= #data.to:getCardIds(Player.Equip)
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    return event == fk.DamageCaused or player.room:askForSkillInvoke(player, self.name, nil, "#mpj-invoke::"..data.to)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TargetSpecified then
      room:doIndicate(player.id, {data.to})
      local to = room:getPlayerById(data.to)
      local cards = room:askForCardsChosen(player, to, 1, to.hp, "he", self.name)
      to:addToPile("$mpj", cards, false, self.name)
    else
      data.damage = data.damage + 1
    end
  end,
  }
  local mpj_delay = fk.CreateTriggerSkill{
  name = "#mpj_delay",
  mute = true,
  events = {fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    return #player:getPile("$mpj") > 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player.room:moveCardTo(player:getPile("$mpj"), Player.Hand, player, fk.ReasonPrey, "mpj")
  end,
  }
  local slashAudio = fk.CreateTriggerSkill{
  name = "#slashAudio",
  refresh_events = {fk.CardUsing},
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(mpj) and data.to ~= player.id and
      data.card.trueName == "slash"
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:broadcastPlaySound("./packages/king/audio/card/slash")
    room:setEmotion(player, "./packages/standard_cards/image/anim/slash")
  end,
  }
  local jianwu = fk.CreateTriggerSkill{
  name = "jianwu",
  events = {fk.GameStart},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return false end
    local room = player.room
    return player:hasEmptyEquipSlot(Card.SubtypeWeapon) and
    room:getCardArea(U.prepareDeriveCards(room, {{"juhua_blade", Card.Diamond, 6}}, "jianwu_derivecards")[1]) == Card.Void
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:moveCardIntoEquip(player, U.prepareDeriveCards(room, {{"juhua_blade", Card.Diamond, 6}}, "jianwu_derivecards"), self.name)
  end,
  }
  mpj:addRelatedSkill(slashAudio)
  mpj:addRelatedSkill(mpj_delay)
  yin__xusheng:addSkill(mpj)
  yin__xusheng:addSkill(yinxianshou)
  yin__xusheng:addSkill(fengsuo)
  yin__xusheng:addSkill(jianwu)
  local moudabaowin = fk.CreateActiveSkill{ name = "moudabao_win_audio" }
  moudabaowin.package = extension
  Fk:addSkill(moudabaowin)
  Fk:loadTranslationTable{
  ["moudabao"] = "谋徐盛",
  ["fengsuo-zhiqu"] = "直取，获得对方一张牌",
  ["fengsuo-chuzheng"] = "出阵，你摸两张牌",
  [":fengsuo-zhiqu"] = "获得对方一张牌",
  [":fengsuo-chuzheng"] = "你摸两张牌",
  ["fengsuo"] = "封锁",
  [":fengsuo"] = "每当你使用【杀】指定其他角色为目标后，你可令其不能响应此【杀】，且所有非锁定技失效直到回合结束。"
  .."然后你可选择：“直取”，则你获得其一张牌；“出阵”，你摸两张牌。",
  ["@@fengsuo-turn"] = "封锁",

  ["yinxianshou"] = "先手",
  [":yinxianshou"] = "其他角色的出牌阶段开始时，你可以选择：是否弃置其一张牌，视为对其使用【杀】。",
  ["#yinxianshou-choice"] = "是否对 %dest 发动 先手，弃置其一张牌，视为对其使用【杀】",
  ["yinxianshou_discard"] = "弃置其一张牌，视为对其使用【杀】",

  ["$mpj1"] = "横刀长江畔，贼子安敢！。",
  ["$mpj2"] = "敌军卸甲怠备，待盛直捣黄龙！",
  ["~moudabao"] = "来日长江激湍阻敌，或是盛忠魂所化……",

  ["$slashAudio"]="破！",
  ["mpj"] = "破军",
  ["#mpj_delay"] = "破军",
  [":mpj"] = "①当你使用【杀】指定一个目标后，你可以将其至多X张牌扣置于该角色的武将牌旁（X为其体力值）；若如此做，当前回合结束时，该角色获得这些牌。②当你使用【杀】对手牌数与装备区里的牌数均不大于你的目标角色造成伤害时，此伤害+1。",

  ["#mpj-invoke"] = "是否对%dest发动 破军",
  ["$mpj"] = "破军",
  ["designer:moudabao"] = "妄生",

  ["jianwu"] = "剑舞",
  [":jianwu"] = "游戏开始时，若你没有武器时，你可以从游戏外获得一把【菊花刀】。",
  ["$jianwu"]="宝刀在手，谁敢试我锋芒！",

  ["$moubabao_win_audio"] = "广陵百里疑城在，不教片帆过江来！",

}

local yin__xujing = General(extension, "yin__xujing", "shu", 3)
  local yin__caixia = fk.CreateTriggerSkill{
  name = "yin__caixia",
  events = {fk.Damage, fk.Damaged, fk.CardUsing,fk.GameStart,fk.EventPhaseStart},
  mute = true,
  can_trigger = function(self, event, target, player, data)
      if event == fk.Damage or event == fk.Damaged or event == fk.CardUsing then
          return player == target and player:hasSkill(self)
        elseif event == fk.EventPhaseStart then
          return target == player and player:hasSkill(self) and player.phase == Player.Start 
      else
          return player:hasSkill(self)
      end
  end,
  on_cost = function(self, event, target, player, data)
      if event == fk.GameStart then
        local room = player.room
        local n = math.min(5, #room.players)
        self.cost_data ={ n , 0 }
        return true
      elseif event == fk.EventPhaseStart then
          local room = player.room
          local n = self.cost_data[1]
          local m = player:getMark("@caixia")
          self.cost_data ={ n , m }
      else
        return true
      end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.GameStart then
      room:setPlayerMark(player, "@caixia", self.cost_data[1])
    elseif event == fk.Damage or event == fk.Damaged or event == fk.CardUsing then
        room:removePlayerMark(player, "@caixia")
          if player:getMark("@caixia") <1 then
            room:drawCards(player,self.cost_data[1], self.name)
            room:setPlayerMark(player, "@caixia", self.cost_data[1])
            if  player:usedSkillTimes(self.name) == self.cost_data[2] then
            local card = room:printCard("crossbow", Card.Heart, 1)
            room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, true, player.id)
            end
          end
    end
  end,
  }
  yin__xujing:addSkill(yin__caixia)
  Fk:loadTranslationTable{
  ["yin__xujing"] = "许靖",
  ["yin__caixia"] = "才瑕",
  [":yin__caixia"] = "当你使用牌数、造成或受到伤害次数累计达到X后，你可以摸X张牌（X为游戏人数且至多为5）,且从游戏外获得一个【诸葛连弩】(每回合限一次）。",
  ["@caixia"] = "才瑕",
}

local yin__bailingyun = General(extension, "yin__bailingyun", "wei", 3, 3, General.Female)
  local yin__linghui = fk.CreateTriggerSkill{
  name = "yin__linghui",
  anim_type = "drawcard",
  events = {fk.EventPhaseStart,fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    if event == fk.EventPhaseStart then
     return player:hasSkill(self) and target.phase == Player.Finish 
    else
     return player:hasSkill(self) and  player == target 
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local ids = room:getNCards(3)
    local use = U.askForUseRealCard(room, player, ids, ".", self.name, "#yin__linghui-use",
    {expand_pile = ids, bypass_times = true}, false, true)
    if use then
      table.removeOne(ids, use.card:getEffectiveId())
    end
    if not player.dead and use then
      room:moveCards{
        ids = table.random(ids, 1),
        to = player.id,
        toArea = Card.PlayerHand,
        moveReason = fk.ReasonJustMove,
        proposer = player.id,
        skillName = self.name,
      }
    end
  end,
  }
  local yin__xiace = fk.CreateTriggerSkill{
  name = "yin__xiace",
  anim_type = "masochism",
  events = {fk.Damage, fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) 
  end,
  on_cost = function(self, event, target, player, data)
    if event == fk.Damage then
      local card = player.room:askForDiscard(player, 1, 1, true, self.name, true, ".", "#yin__xiace-recover", true)
      if #card > 0 then
        self.cost_data = card
        return true
      end
    else
      local room = player.room
      local targets = table.map(room:getOtherPlayers(player, false), Util.IdMapper)
      targets = room:askForChoosePlayers(player, targets, 1, 1, "#yin__xiace-control", self.name, true)
      if #targets > 0 then
        self.cost_data = targets[1]
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.Damage then
      room:throwCard(self.cost_data, self.name, player)
      if not player.dead and player:isWounded() then
        room:recover {
          who = player,
          num = 1,
          recoverBy = player,
          skillName = self.name,
        }
      end
    else
      local tar = room:getPlayerById(self.cost_data)
      room:addPlayerMark(tar, "@@yin__xiace")
    end
  end
  }
  local yin__xiace_nullify = fk.CreateInvaliditySkill {
  name = "#yin__xiace_nullify",
  invalidity_func = function(self, from, skill)
    return from:getMark("@@yin__xiace") > 0 and skill:isPlayerSkill(from)
  end
  }
  local yin__xiace_Refresh = fk.CreateTriggerSkill{
  name = "#yin__xiace_Refresh",
  refresh_events = { fk.AfterTurnEnd, },
  can_refresh = function(self, event, target, player, data)
    if event == fk.AfterTurnEnd then
      return
        target == player and
        table.find(
          { "@@yin__xiace"},
          function(markName) return player:getMark(markName) ~= 0 end
        )
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    if event == fk.AfterTurnEnd then
      for _, markName in ipairs({ "@@yin__xiace" }) do
        if player:getMark(markName) ~= 0 then
          room:setPlayerMark(player, markName, 0)
          end
        end
      end
  end,
  }
  local yin__yuxin = fk.CreateTriggerSkill{
  name = "yin__yuxin",
  frequency = Skill.Limited,
  events = {fk.EnterDying},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if room:askForSkillInvoke(player, self.name, nil, "#yuxin-invoke::"..target.id) then
      room:doIndicate(player.id, {target.id})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:recover {
      who = target,
      num = player.maxHp - target.hp,
      recoverBy = player,
      skillName = self.name,
    }
  end,
  }
  yin__xiace:addRelatedSkill(yin__xiace_Refresh)
  yin__xiace:addRelatedSkill(yin__xiace_nullify)
  yin__bailingyun:addSkill(yin__linghui)
  yin__bailingyun:addSkill(yin__xiace)
  yin__bailingyun:addSkill(yin__yuxin)

  Fk:loadTranslationTable{
  ["yin__bailingyun"] = "柏灵筠",
  ["yin__linghui"] = "灵慧",
  [":yin__linghui"] = "你的结束阶段或当你受到伤害后，"..
  "你可以观看牌堆顶的三张牌，你可以使用其中一张牌，然后随机获得剩余牌中的一张。",
  ["yin__xiace"] = "黠策",
  [":yin__xiace"] = "当你受到伤害后，你可令一名其他角色的所有非锁定技失效直到其回合结束；"..
  "当你造成伤害后，你可以弃置一张牌并回复1点体力。",
  ["yin__yuxin"] = "御心",
  [":yin__yuxin"] = "限定技，当一名角色进入濒死状态时，你可以令其回复体力至X点（X为你的体力上限）。",

  ["#yin__linghui-use"] = "灵慧：你可以使用其中的一张牌，然后获得剩余的随机一张",
  ["#yin__xiace-recover"] = "是否发动 黠策，弃置一张牌来回复1点体力",
  ["#yin__xiace-control"] = "是否发动 黠策，选择一名其他角色，令其本回合所有非锁定技失效",
  ["@@yin__xiace"] = "黠策",
  ["#yin__yuxin-invoke"] = "是否对 %dest 发动 御心",

}

local yin__caopi = General(extension, "yin__caopi", "wei", 3)
  local yin__xingshang = fk.CreateTriggerSkill{
  name = "yin__xingshang",
  anim_type = "drawcard",
  events = {fk.Death},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and not target:isNude()
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards_id = target:getCardIds{Player.Hand, Player.Equip}
    room:obtainCard(player.id, cards_id, false, fk.ReasonPrey)
    room:recover({
      who = player,
      num = 1,
      recoverBy = player,
      skillName = self.name,
    })
  end,
  }
  local yin__fangzhu = fk.CreateTriggerSkill{
  name = "yin__fangzhu",
  anim_type = "masochism",
  events = {fk.Damaged},
  on_cost = function(self, event, target, player, data)
    local to = player.room:askForChoosePlayers(player, table.map(player.room:getOtherPlayers(player), Util.IdMapper)
    , 1, 1, "#yin__fangzhu-choose:::", self.name, true)
    if #to > 0 then
      self.cost_data = {tos = to}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = player.room:getPlayerById(self.cost_data.tos[1])
    local choices = {
      "yin__fangzhu_got",--获得牌
      "yin__fangzhu_only_basic",--只能基本
      "yin__fangzhu_only_trick",--只能锦囊  
      "yin__fangzhu_nullify_skill",--技能无效
      "yin__fangzhu_disresponsable",--不能相应
      "yin__fangzhu_turn_over",--翻面
      --"yin__fangzhu_all",--背水
    }
    local choice = player.room:askForChoice(player, choices, self.name)
    if choice == "yin__fangzhu_got" then
      room:moveCardTo(to:getCardIds("h"), Card.PlayerHand, player, fk.ReasonPrey, self.name, nil, false, player.id)
      room:loseHp(to, 1, self.name)
    elseif choice == "yin__fangzhu_only_basic" then
      room:setPlayerMark(to, "@@yin__fangzhu_only_basic", 1)
    elseif choice == "yin__fangzhu_only_trick" then 
      room:setPlayerMark(to, "@@yin__fangzhu_only_trick", 1)
    elseif choice == "yin__fangzhu_nullify_skill" then
      room:setPlayerMark(to, "@@yin__fangzhu_nullify_skill", 1)
    elseif choice == "yin__fangzhu_disresponsable" then
      room:setPlayerMark(to, "@@yin__fangzhu_disresponsable", 1)
    elseif choice == "yin__fangzhu_turn_over" then
      to:turnOver()
   --[[ elseif choice == "yin__fangzhu_all" then
      room:loseHp(player, 1, self.name)
      if player:isAlive() then
      room:moveCardTo(to:getCardIds("h"), Card.PlayerHand, player, fk.ReasonPrey, self.name, nil, false, player.id)
      room:loseHp(to, 1, self.name)
      room:setPlayerMark(to, "@@yin__fangzhu_only_basic", 1)
      room:setPlayerMark(to, "@@yin__fangzhu_only_trick", 1)
      room:setPlayerMark(to, "@@yin__fangzhu_nullify_skill", 1)
      room:setPlayerMark(to, "@@yin__fangzhu_disresponsable", 1)
      to:turnOver()
      end]]
    end
  end,
  }
  local yin__fangzhu_Refresh = fk.CreateTriggerSkill{
  name = "#yin__fangzhu_Refresh",
  refresh_events = { fk.AfterTurnEnd, fk.CardUsing },
  can_refresh = function(self, event, target, player, data)
    if event == fk.AfterTurnEnd then
      return
        target == player and
        table.find(
          { "@@yin__fangzhu_only_basic", "@@yin__fangzhu_only_trick", "@@yin__fangzhu_nullify_skill", "@@yin__fangzhu_disresponsable" },
          function(markName) return player:getMark(markName) ~= 0 end
        )
    end

    return
      target == player and
      table.find(
        player.room.alive_players,
        function(p) return p:getMark("@@yin__fangzhu_disresponsable") > 0 and p ~= target end
      )
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room

    if event == fk.AfterTurnEnd then
      for _, markName in ipairs({ "@@yin__fangzhu_only_basic", "@@yin__fangzhu_only_trick", "@@yin__fangzhu_nullify_skill", "@@yin__fangzhu_disresponsable" }) do
        if player:getMark(markName) ~= 0 then
          room:setPlayerMark(player, markName, 0)
        end
      end
    else
      data.disresponsiveList = data.disresponsiveList or {}
      local tos = table.filter(
        player.room.alive_players,
        function(p) return p:getMark("@@yin__fangzhu_disresponsable") > 0 and p ~= target end
      )
      table.insertTableIfNeed(data.disresponsiveList, table.map(tos, Util.IdMapper))
    end
  end,
  }
  local yin__fangzhu_prohibit = fk.CreateProhibitSkill{
  name = "#yin__fangzhu_prohibit",
  prohibit_use = function(self, player, card)
    if player:getMark("@@yin__fangzhu_only_basic") ~= 0 then
      return card.type == Card.TypeTrick
    elseif player:getMark("@@yin__fangzhu_only_trick") ~= 0 then
      return card.type == Card.TypeBasic
    else
      return false
    end
  end,
  }
  local yin__fangzhu_nullify = fk.CreateInvaliditySkill {
  name = "#yin__fangzhu_nullify",
  invalidity_func = function(self, from, skill)
    return from:getMark("@@yin__fangzhu_nullify_skill") > 0 and skill:isPlayerSkill(from)
  end
  }
  yin__fangzhu:addRelatedSkill(yin__fangzhu_Refresh)
  yin__fangzhu:addRelatedSkill(yin__fangzhu_prohibit)
  yin__fangzhu:addRelatedSkill(yin__fangzhu_nullify)
  yin__caopi:addSkill(yin__xingshang)
  yin__caopi:addSkill(yin__fangzhu)
  yin__caopi:addSkill("songwei")
  Fk:loadTranslationTable{
  ["yin__caopi"] = "曹丕",

  ["yin__xingshang"] = "行殇",
  [":yin__xingshang"] = "当其他角色死亡时，你获得其所有牌并回复1点体力。",
  ["yin__fangzhu"] = "放逐",
  [":yin__fangzhu"] = "当你受到伤害后，你可以选择一项指定一名其他角色：获得其所有手牌并让其失去1点体力；其翻面；"..
  "其技能失效直到其回合结束；其不能使用除基本牌外的手牌直到其回合结束；其不能打出除锦囊牌外的手牌直到其回合结束；其不能响应除其外的角色使用的牌。",--7.背水：失去一点体力

  ["#yin__fangzhu-choose"] = "放逐：你可选择一名其他角色执行效果",
  ["@@yin__fangzhu_only_basic"] = "放逐限基本",
  ["@@yin__fangzhu_only_trick"] = "放逐限锦囊",
  ["@@yin__fangzhu_nullify_skill"] = "放逐 技能失效",
  ["@@yin__fangzhu_disresponsable"] = "放逐 不可响应",

  ["yin__fangzhu_got"] = "获得所有牌并失去体力",
  ["yin__fangzhu_only_basic"] = "限基本",
  ["yin__fangzhu_only_trick"] = "限锦囊",
  ["yin__fangzhu_nullify_skill"] = "技能失效",
  ["yin__fangzhu_disresponsable"] = "不可响应",
  ["yin__fangzhu_turn_over"] = "翻面",
  --["yin__fangzhu_all"] = "背水:失去一点体力",
}



local yin__guojia = General(extension, "yin__guojia", "wei", 3)
  local yin__yiji = fk.CreateTriggerSkill{
  name = "yin__yiji",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.Damaged,fk.HpLost},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) 
  end,
  on_trigger = function(self, event, target, player, data)
    if event == fk.Damaged  then
    local ret
    for i = 1, data.damage do
      ret = self:doCost(event, target, player, data)
      if ret then return ret end
    end
    else
      for _ = 1, data.num do
        if not player:hasSkill(self) then break end
        self:doCost(event, target, player, data)
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if event == fk.Damaged then
    local to = room:askForChoosePlayers(player, table.map(player.room.alive_players, Util.IdMapper), 1, 1, "#yin__yiji_damaged-choose", self.name, true)
    if #to > 0 then
      self.cost_data = {tos = to}
      return true
    end
  else
    local to = room:askForChoosePlayers(player, table.map(player.room.alive_players, Util.IdMapper), 1, 1, "#yin__yiji_lost-choose", self.name, true)
    if #to > 0 then
      self.cost_data = {tos = to}
      return true
    end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = player.room:getPlayerById(self.cost_data.tos[1])
    if event == fk.Damaged then
    room:drawCards(to,2, self.name)
    else
    room:drawCards(to,3, self.name)
  end
  end,
  }
  yin__guojia:addSkill(yin__yiji)
  Fk:loadTranslationTable{
    ["yin__guojia"] = "郭嘉",
    ["yin__yiji"] = "遗计",
    [":yin__yiji"] = "当场上有角色受到1点伤害后，你可以令一名角色摸两张牌。当场上有角色失去1点体力后，你可以令一名角色摸三张牌。",
    ["#yin__yiji_damaged-choose"] = "遗计：令一名角色摸两张牌",
    ["#yin__yiji_lost-choose"] = "遗计：令一名角色摸三张牌",
}


local yin__xiahoudun = General(extension, "yin__xiahoudun", "wei", 4)
  local yin__ganglie = fk.CreateTriggerSkill{
    name = "yin__ganglie",
    anim_type = "masochism",
    events = {fk.Damaged},
    can_trigger = function(self, event, target, player, data)
      return player:hasSkill(self) and not target.dead
    end,
    on_trigger = function(self, event, target, player, data)
      if event == fk.Damaged  then
      local ret
      for i = 1, data.damage do
        ret = self:doCost(event, target, player, data)
        if ret then return ret end
      end
      end
    end,
    on_cost = function(self, event, target, player, data)
      local room = player.room
      if event == fk.Damaged then
      local to = room:askForChoosePlayers(player, table.map(player.room.alive_players, Util.IdMapper), 1, 1, "#yin__ganglie-invoke", self.name, true)
      if #to > 0 then
        self.cost_data = {tos = to}
        return true
      end
    end
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      local to = player.room:getPlayerById(self.cost_data.tos[1])
      local judge = {
        who = player,
        reason = self.name,
        pattern = ".",
      }
      room:judge(judge)
      if not to or to.dead then return false end
      if judge.card.color == Card.Red then
        room:damage{
          from = player,
          to = to,
          damage = 1,
          skillName = self.name,
        }
      elseif judge.card.color == Card.Black and not to:isNude() then
        local cid = room:askForCardChosen(player, to, "he", self.name)
        room:throwCard({cid}, self.name, to, player)
      end
    end
  }
  yin__xiahoudun:addSkill(yin__ganglie)
  Fk:loadTranslationTable{
    ["yin__xiahoudun"] = "夏侯惇",
    ["yin__ganglie"] = "刚烈",
    [":yin__ganglie"] = "当场上玩家受到1点伤害后，你可判定，若结果为：红色，你对一名角色造成1点伤害；黑色，你弃置一名角色的一张牌。",

    ["#yin__ganglie-invoke"] = "选择一名玩家对其发动 刚烈，判红对其造成伤害，判黑弃其牌"

}

local yin__zhonghui = General(extension, "yin__zhonghui", "wei", 4)
  local yin__quanji = fk.CreateTriggerSkill{
  name = "yin__quanji",
  events = {fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) 
  end,
  on_trigger = function(self, event, target, player, data)
    local ret
    for i = 1, data.damage do
      ret = self:doCost(event, target, player, data)
      if ret then return ret end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:drawCards(player,1, self.name)
    room:addPlayerMark(player, "@yin__quan",1)
  end,
  }
  local yin__quanji_maxcards = fk.CreateMaxCardsSkill{
  name = "#yin__quanji_maxcards",
  correct_func = function(self, player)
    if player:hasSkill(yin__quanji) then
      return player:getMark("@yin__quan")
    else
      return 0
    end
  end,
  }
  local yin__zili = fk.CreateTriggerSkill{
  name = "yin__zili",
  frequency = Skill.Wake,
  events = {fk.EventPhaseStart,fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and
      player.phase == Player.Start and
      player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  can_wake = function(self, event, target, player, data)
    return event == fk.EventPhaseStart and player:getMark("@yin__quan") > 2 
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choices = {"draw2"}
    if player:isWounded() then
      table.insert(choices, "recover")
    end
    local choice = room:askForChoice(player, choices, self.name, nil, nil, {"draw2", "recover"})
    if choice == "draw2" then
      room:drawCards(player, 2, self.name)
    else
      room:recover({
        who = player,
        num = 1,
        recoverBy = player,
        skillName = self.name
      })
    end
    room:changeMaxHp(player, -1)
    room:handleAddLoseSkills(player, "yin__paiyi", nil)
  end,
  }
  local yin__zhili_extra = fk.CreateTriggerSkill{
    name = "#yin__zhili_extra",
    events = {fk.TurnEnd},
    can_trigger = function(self, event, target, player, data)
      if event == fk.TurnEnd and player:getMark("@yin__quan") > 2 and player:usedSkillTimes(self.name,Player.HistoryGame)==0 then
        return true
      end
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
      player:gainAnExtraTurn(true, self.name)
    end
  }
  local yin__paiyi = fk.CreateActiveSkill{
  name = "yin__paiyi",
  anim_type = "control",
  prompt = "#yin__paiyi-active",
  can_use = function(self, player)
    return player:getMark("@yin__quan") > 1 and player:usedSkillTimes(self.name)==0
  end,
  card_num = 0,
  target_num = 1,
  target_filter = function(self, to_select, selected)
    return #selected < 1  
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    room:removePlayerMark(player, "@yin__quan", 1)
    local target = room:getPlayerById(effect.tos[1])
    local x = target:getHandcardNum() - (2 * player:getMark("@yin__quan"))
    if x > 0 then
      room:askForDiscard(target, x, x, true, self.name, false)
    else
      room:drawCards(target, -x, self.name)
    end
    if target.id ~= player.id then
      room:damage{ from = player, to = target, damage = 1, skillName = self.name } 
    end
  end,
  }
  yin__zili:addRelatedSkill(yin__zhili_extra)
  yin__quanji:addRelatedSkill(yin__quanji_maxcards)
  yin__zhonghui:addSkill(yin__quanji)
  yin__zhonghui:addSkill(yin__zili)
  yin__zhonghui:addRelatedSkill(yin__paiyi)
  Fk:loadTranslationTable{
    ["yin__zhonghui"] = "钟会",
    ["yin__quanji"] = "权计",
    [":yin__quanji"] = "当场上角色受到1点伤害后，你可以摸一张牌，然后获得1个“权”；你的手牌上限+X（X为“权”数）。",
    ["yin__zili"] = "自立",
    [":yin__zili"] = "觉醒技，若“权”的数量不小于3，当前回合结束后，你获得一个额外回合，然后准备阶段：你选择一项：1.回复1点体力；2.摸两张牌。然后减1点体力上限，获得“排异”。",
    ["yin__paiyi"] = "排异",
    [":yin__paiyi"] = "出牌阶段限一次，你可以移去一点“权”，令一名角色摸至或弃置两倍的“权”的数量。若该角色不为你，你对其造成1点伤害。",
    ["@yin__quan"] = "权",
    ["yin__paiyi_drawcard"] = "排异：令一名角色手牌数量调整为两倍“权”的数量",
    ["yin__paiyi_discard"] = "将手牌数量弃置至两倍“权”的数量",
}

local yin__xushao = General(extension, "yin__xushao", "qun", 3)

---@param player ServerPlayer
local addTYPingjianSkill = function(player, skill_name)
  local room = player.room
  local skill = Fk.skills[skill_name]
  if skill == nil or player:hasSkill(skill_name, true) then return false end
  room:handleAddLoseSkills(player, skill_name, nil)
  --[[room:addTableMarkIfNeed(player, "ty__pingjian_skills", skill_name)
  local pingjian_skill_times = player:getTableMark("ty__pingjian_skill_times")
  table.insert(pingjian_skill_times, {skill_name, player:usedSkillTimes(skill_name)})
  for _, s in ipairs(skill.related_skills) do
    table.insert(pingjian_skill_times, {s.name, player:usedSkillTimes(s.name)})
  end
  room:setPlayerMark(player, "ty__pingjian_skill_times", pingjian_skill_times)]]
end

---@param player ServerPlayer
local removeTYPingjianSkill = function(player, skill_name)
  local room = player.room
  local skill = Fk.skills[skill_name]
  if skill == nil then return false end
  room:handleAddLoseSkills(player, "-" .. skill_name, nil)
  room:removeTableMark(player, "ty__pingjian_skills", skill_name)
  local invoked = false
  local pingjian_skill_times = player:getTableMark("ty__pingjian_skill_times")
  local record_copy = {}
  for _, pingjian_record in ipairs(pingjian_skill_times) do
    if #pingjian_record == 2 then
      local record_name = pingjian_record[1]
      if record_name == skill_name or not table.every(skill.related_skills, function (s)
          return s.name ~= record_name end) then
        if player:usedSkillTimes(record_name) > pingjian_record[2] then
          invoked = true
        end
      else
        table.insert(record_copy, pingjian_record)
      end
    end
  end
  room:setPlayerMark(player, "ty__pingjian_skill_times", record_copy)
end

local function getPingjianSkills(player, event)
  local list = {
    ["play"] = {
      "qiangwu", "ol_ex__qiangxi", "ol_ex__luanji", "ty_ex__sanyao", "ol__xuehen", "ex__yijue", "daoshu", "m_ex__xianzhen",
      "tianyi", "mansi", "ty__lianji", "ty_ex__wurong", "xuezhao", "hs__kurou", "m_ex__mieji",
      "ex__zhiheng", "ex__guose", "guolun", "duliang", "os__gongxin", "lueming", "jijie", "busuan", "minsi", "ty__lianzhu",
      "ex__fanjian", "tanbei", "ty__qingcheng", "jinhui", "weimeng", "ty__songshu", "poxi", "m_ex__ganlu", "ty__kuangfu", "qice",
      "ty_ex__gongqi", "ty_ex__huaiyi", "shanxi", "cuijian", "ol_ex__tiaoxin", "qingnang", "quji", "ty_ex__anguo", "ex__jieyin",
      "m_ex__anxu", "ty_ex__mingce", "ziyuan", "mou__lijian", "mingjian", "ex__rende", "mizhao", "yanjiao", "ol_ex__dimeng",
      "quhu", "tunan", "nuchen", "feijun", "yingshui", "qiongying", "zigu", "weiwu", "chiying",

      "yangjie", "m_ex__junxing", "m_ex__yanzhu", "ol_ex__changbiao", "yanxi", "xuanbei", "yushen", "guanxu",
      "ty__jianji", "wencan", "xiangmian", "zhuren", "changqu", "jiuxianc", "caizhuang", "ty__beini", "jichun", "tongwei",
      "liangyan", "kuizhen", "huiji",
    },
    [fk.Damaged] = {
      "guixin", "ty__benyu", "ex__fankui", "ex__ganglie", "ex__yiji", "ex__jianxiong", "os_ex__enyuan", "chouce", "ol_ex__jieming",
      "fangzhu", "ty_ex__chengxiang", "huituo", "ty__wangxi", "yuce", "zhichi", "ty_ex__zhiyu", "wanggui", "qianlong", "dingcuo",
      "peiqi",

      "ty__jilei", "xianchou", "liejie", "os__fupan", "yuqi", "silun", "yashi", "qingxian", "xiace", "fumou",
    },
    [fk.EventPhaseStart] = {
      "ty_ex__zhiyan", "ex__biyue", "zuilun", "mozhi", "fujian", "kunfen", "ol_ex__jushou", "os_ex__bingyi", "miji", "zhengu",
      "juece", "sp__youdi", "kuanshi", "ty__jieying", "suizheng", "m_ex__jieyue",

      "shenfu", "meihun", "pijing", "zhuihuan", "os__juchen", "os__xingbu", "ty_ex__jingce", "nuanhui", "sangu",
      "js__pianchong", "linghui", "huayi", "jue",
    },
  }
  local used_skills = player:getTableMark("ty__pingjian_used_skills")
  return table.filter(list[event] or {}, function (skill_name)
    return Fk.skills[skill_name] and not table.contains(used_skills, skill_name) and not player:hasSkill(skill_name, true)
  end)
end

local yin__pingjian = fk.CreateActiveSkill{
  name = "yin__pingjian",
  prompt = "#yin__pingjian-active",
  card_num = 0,
  target_num = 0,
  can_use = function(self, player)
    return player:getMark("yin__pingjian_used-phase") == 0
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    room:setPlayerMark(player, "yin__pingjian_used-phase", 1)
    local skills = getPingjianSkills(player, "play")
    if #skills == 0 then return false end
    local choices = table.random(skills, 3)
    local skill_name = room:askForChoice(player, choices, self.name, "#yin__pingjian-choice", true)
    room:addTableMark(player, "yin__pingjian_used_skills", skill_name)
    local phase_event = room.logic:getCurrentEvent():findParent(GameEvent.Phase)
    if phase_event ~= nil then
      addTYPingjianSkill(player, skill_name)
    end
  end,
}
local yin__pingjian_trigger = fk.CreateTriggerSkill{
  name = "#yin__pingjian_trigger",
  events = {fk.Damaged, fk.EventPhaseStart},
  main_skill = yin__pingjian,
  mute = true,
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(yin__pingjian) or player ~= target then return false end
    if event == fk.Damaged then
      return true
    elseif event == fk.EventPhaseStart then
      return player.phase == Player.Finish
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:notifySkillInvoked(player, yin__pingjian.name)
    player:broadcastSkillInvoke(yin__pingjian.name)
    local skills = getPingjianSkills(player, event)
    if #skills == 0 then return false end
    local choices = table.random(skills, 3)
    local skill_name = room:askForChoice(player, choices, yin__pingjian.name, "#yin__pingjian-choice", true)
    room:addTableMark(player, "yin__pingjian_used_skills", skill_name)
    local skill = Fk.skills[skill_name]
    if skill == nil then return false end

    addTYPingjianSkill(player, skill_name)
    if skill:triggerable(event, target, player, data) then
      skill:trigger(event, target, player, data)
    end
  end,
}

yin__pingjian:addRelatedSkill(yin__pingjian_trigger)
yin__xushao:addSkill(yin__pingjian)
Fk:loadTranslationTable{
  ["yin__xushao"] = "许劭",

  ["yin__pingjian"] = "评荐",
  ["#ty__pingjian_trigger"] = "评荐",
  [":yin__pingjian"] = "出牌阶段，或结束阶段，或当你受到伤害后，你可以从对应时机的技能池中随机抽取三个技能，"..
  "然后你选择并获得其中一个技能。",

  ["#yin__pingjian-active"] = "发动 评荐，从三个出牌阶段的技能中选择一个获得",
  ["yin__pingjian-choice"] = "评荐：选择要获得的技能",

}


local yin__caocao = General(extension, "yin__caocao", "wei", 4)
local yin__jianxiong = fk.CreateTriggerSkill{
  name = "yin__jianxiong",
  anim_type = "masochism",
  events = {fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    return  player:hasSkill(self) and data.card and player.room:getCardArea(data.card) == Card.Processing
  end,
  on_use = function(self, event, target, player, data)
    player.room:obtainCard(player.id, data.card, true, fk.ReasonJustMove)
    player:drawCards(1, self.name)
  end,
}
yin__caocao:addSkill(yin__jianxiong)
Fk:loadTranslationTable{
  ["yin__caocao"] = "曹操",

  ["yin__jianxiong"] = "奸雄",
  [":yin__jianxiong"] = "当场上角色受到伤害后，你可以获得造成伤害的牌,然后摸一张牌",

}

local yin__zhangfei = General(extension, "yin__zhangfei", "shu", 4)
local yin__paoxiao = fk.CreateActiveSkill{
  name = "yin__paoxiao",
  card_num = 1,
  target_num = 1,
  can_use = function(self, player)
    return not player:isKongcheng() and player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = function(self, to_select, selected)
    return #selected == 0 
  end,
  target_filter = function(self, to_select, selected, selected_cards)
    return #selected == 0 and to_select ~= Self.id
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local to = room:getPlayerById(effect.tos[1])
    local num = Fk:getCardById(effect.cards[1]).number
    room:throwCard(effect.cards[1], self.name, player, player)
    room:setPlayerMark(player, "@yin__paoxiao-turn", num)
    room:setPlayerMark(to, "@@yin__paoxiao_ed-turn",1)   
    local cards = room:askForDiscard(player, 1, num, true, self.name, true, ".", "#yin__paoxiao-cost:::"..tostring(num), true)
    if #cards > 0 then
      room:throwCard(cards, self.name, player, player)
      for i = 1, #cards, 1 do
        if player.dead or to.dead or not room:useVirtualCard("slash", nil, player, to, self.name, true) then
          break
        else
          room:removePlayerMark(player, "@yin__paoxiao-turn", 1)
        end
    end
    if to.dead then
      room:drawCards(player, player:getMark("@yin__paoxiao-turn"))
      room:setPlayerMark(player, "@yin__paoxiao-turn", 0)
      player:addSkillUseHistory(self.name, -1)
    else
      room:loseHp(player, 1, "yin__paoxiao")
    end
  end
end,
}
yin__zhangfei:addSkill(yin__paoxiao)
Fk:loadTranslationTable{
  ["yin__zhangfei"] = "张飞",

  ["yin__paoxiao"] = "咆哮",
  [":yin__paoxiao"] = "出牌阶段限一次，你可以弃置一张手牌并选择一名其他角色，记录该牌的点数X，然后你可以弃置至多X张牌，视为对其使用等量张的【杀】，若此杀结算结束前其死亡，则你摸X减去本次使用的杀的数量张牌，然后本回合此技能视为未发动过，若其未因此死亡，则你失去一点体力",
  ["#yin__paoxiao-cost"] = "咆哮：你可以弃置至多%arg张牌，",
  ["@yin__paoxiao-turn"] = "咆哮",
  ["@@yin__paoxiao_ed-turn"] = "被咆哮",
  ["#yin__paoxiao-slash"] = "咆哮：你可以视为使用【杀】！", 
}

local yin__duyu = General(extension, "yin__duyu", "qun", 4)
yin__duyu.subkingdom = "jin"
local yin__duyuWin = fk.CreateActiveSkill{ name = "yin__duyu_win_audio" }
yin__duyuWin.package = extension
Fk:addSkill(yin__duyuWin)

local yin__duyu2 = General(extension, "yin2__duyu", "qun", 4)
yin__duyu2.subkingdom = "jin"
local yin__duyu2Win = fk.CreateActiveSkill{ name = "yin2__duyu_win_audio" }
yin__duyu2Win.package = extension
Fk:addSkill(yin__duyu2Win)
yin__duyu2.hidden = true

local yin__wuku = fk.CreateTriggerSkill{
  name = "yin__wuku",
  events = {fk.CardUsing},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player:getMark("@yin__wuku") < 99 and data.card.type == Card.TypeEquip
  end,
  on_use = function(self, event, target, player)
    player.room:addPlayerMark(player, "@yin__wuku")
    player:drawCards(1, self.name)
  end,
}
local yin__sanchen = fk.CreateTriggerSkill{
  name = "yin__sanchen",
  frequency = Skill.Wake,
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and
      player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  can_wake = function(self, event, target, player, data)
    return player:getMark("@yin__wuku") == 3
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room

    if player.general == "yin__duyu" then
      player.general = "yin2__duyu"
      room:broadcastProperty(player, "general")
    elseif player.deputyGeneral == "yin__duyu" then
      player.deputyGeneral = "yin2__duyu"
      room:broadcastProperty(player, "deputyGeneral")
    end

    room:changeMaxHp(player, 1)
    if player:isWounded() then
      room:recover{ who = player, num = 1, skillName = self.name }
    end
    room:handleAddLoseSkills(player, "yin__miewu", nil)
  end,
}
local yin__miewu = fk.CreateViewAsSkill{
  name = "yin__miewu",
  pattern = ".",
  interaction = function()
    local names, all_names = {} , {}
    for _, id in ipairs(Fk:getAllCardIds()) do
      local card = Fk:getCardById(id)
      if (card.type == Card.TypeBasic or card.type == Card.TypeTrick) and not card.is_derived and not table.contains(all_names, card.name) then
        table.insert(all_names, card.name)
        local to_use = Fk:cloneCard(card.name)
        if ((Fk.currentResponsePattern == nil and Self:canUse(to_use) and not Self:prohibitUse(to_use)) or
        (Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(to_use))) then
          table.insert(names, card.name)
        end
      end
    end
    if #names == 0 then return false end
    return UI.ComboBox { choices = names, all_choices = all_names }
  end,
  view_as = function(self, cards)
    if  not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = self.name
    return card
  end,
  before_use = function(self, player, use)
    player.room:removePlayerMark(player, "@yin__wuku")
  end,
  enabled_at_play = function(self, player)
    return player:getMark("@yin__wuku") > 0 
  end,
  enabled_at_response = function(self, player, response)
    return player:getMark("@yin__wuku") > 0 
  end,
}
local yin__miewu_delay = fk.CreateTriggerSkill{
  name = "#yin__miewu_delay",
  events = {fk.CardUseFinished, fk.CardRespondFinished},
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return not player.dead and player == target and table.contains(data.card.skillNames, yin__miewu.name)
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, yin__miewu.name)
  end,
}
local ex_nihiloAudio = fk.CreateTriggerSkill{
  name = "#ex_nihiloAudio",
  refresh_events = {fk.CardUsing},
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.trueName == "ex_nihilo"
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:broadcastPlaySound("./packages/king/audio/card/yin_duyu_ex_nihilo")
    room:setEmotion(player, "./packages/standard_cards/image/anim/ex_nihilo")
  end,
}
local nullificationAudio = fk.CreateTriggerSkill{
  name = "#nullificationAudio",
  refresh_events = {fk.CardUsing},
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.trueName == "nullification"
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:broadcastPlaySound("./packages/king/audio/card/yin_duyu_nullification")
    room:setEmotion(player, "./packages/standard_cards/image/anim/nullification")
  end,
}
local analepticAudio = fk.CreateTriggerSkill{
  name = "#analepticAudio",
  refresh_events = {fk.CardUsing},
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.trueName == "analeptic"
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:broadcastPlaySound("./packages/king/audio/card/yin_duyu_analeptic")
    room:setEmotion(player, "./packages/standard_cards/image/anim/analeptic")
  end,
}
local fire_attackAudio = fk.CreateTriggerSkill{
  name = "#analepticAudio",
  refresh_events = {fk.CardUsing},
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.trueName == "fire_attack" 
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:broadcastPlaySound("./packages/king/audio/card/yin_duyu_fire_attack")
    room:setEmotion(player, "./packages/standard_cards/image/anim/fire_attack")
  end,
}
yin__duyu:addSkill(yin__wuku)
yin__duyu:addSkill(fire_attackAudio)
yin__duyu:addSkill(ex_nihiloAudio)
yin__duyu:addSkill(analepticAudio)
yin__duyu:addSkill(nullificationAudio)
yin__duyu:addSkill(yin__sanchen)
yin__miewu:addRelatedSkill(yin__miewu_delay)
yin__duyu:addRelatedSkill(yin__miewu)

yin__duyu2:addSkill(yin__wuku.name)
yin__duyu2:addSkill(yin__sanchen.name)
yin__duyu2:addRelatedSkill(yin__miewu.name)
yin__duyu2:addSkill(fire_attackAudio.name)
yin__duyu2:addSkill(ex_nihiloAudio.name)
yin__duyu2:addSkill(analepticAudio.name)
yin__duyu2:addSkill(nullificationAudio.name)
Fk:loadTranslationTable{
  ["yin__duyu"] = "杜预",
  ["yin2"] = "阴",
  ["yin2__duyu"] = "杜预",

  ["yin__wuku"] = "武库",
  [":yin__wuku"] = "锁定技，当一名角色使用装备时，你获得1个“武库”标记，并摸一张牌。（“武库”数量至多为99）",
  ["yin__sanchen"] = "三陈",
  [":yin__sanchen"] = "觉醒技，若你已有3个“武库”，你增加一点体力上限，回复一点体力，然后获得技能〖灭吴〗。",
  ["@yin__wuku"] = "武库",
  ["yin__miewu"] = "灭吴",
  ["#yin__miewu_delay"] = "灭吴",
  [":yin__miewu"] = "你可以弃置1个“武库”，视为使用或打出任意一张基本牌或锦囊牌；最后你摸一张牌。",

  ["$yin__wuku1"] = "人非生而知之，但敏而求之也。",
  ["$yin__wuku2"] = "广习经籍，只为上能弼国，下可安民。",

  ["$yin__sanchen1"] = "今便可荡平吴都，陛下何舍而不取？",
  ["$yin__sanchen2"] = "天下思定已久，陛下当成四海之愿。",

  ["$yin__wuku_yin2__duyu1"] = "千计万策，随江即来也。",
  ["$yin__wuku_yin2__duyu2"] = "万结之绳，不过一剑即解。",

  ["$yin__miewu_yin2__duyu1"] = "驭虬吞江为平地，剑指东南定吴夷。",
  ["$yin__miewu_yin2__duyu2"] = "九州从来向一统，岂容伪朝至两分？",

  ["$yin__duyu_win_audio"] = "天下速定，幸无须我全力而为。",
  ["$yin2__duyu_win_audio"] = "吴贼倡乱非为坐视，窃国害民必受后诛。",

  ["$ex_nihiloAudio"]= "广研群经，自无所不有也。",
  ["$nullificationAudio"]= "今大势已定，汝设千计亦难阻。",
  ["$analepticAudio"]= "此乃待胜之物。",
  ["$fire_attackAudio"]= "起火巴山，乱敌腹心。",

  ["~yin__duyu"] = "吾勤加追琢，然终未有圭璋之期……",
  ["~yin2__duyu"] = "此魂弃归泰山，永镇不轨之贼……",
}


local yin__zhugeke = General(extension, "yin__zhugeke", "wu", 3)
local yin__aocai = fk.CreateViewAsSkill{
  name = "yin__aocai",
  pattern = ".",
  anim_type = "special",
  expand_pile = function()
    return Self:getTableMark("yin__aocai")
  end,
  prompt = "#yin__aocai",
  card_filter = function(self, to_select, selected)
    if #selected == 0 and table.contains(Self:getTableMark("yin__aocai"), to_select) then
      local card = Fk:getCardById(to_select)
        if Fk.currentResponsePattern == nil then
          return Self:canUse(card) and not Self:prohibitUse(card)
        else
          return Exppattern:Parse(Fk.currentResponsePattern):match(card)
      end
    end
  end,
  view_as = function(self, cards)
    if #cards ~= 1 then return end
    return Fk:getCardById(cards[1])
  end,
  enabled_at_response = function(self, player, response)
    return not response 
  end,
}
local yin__aocai_trigger = fk.CreateTriggerSkill{
  name = "#yin__aocai_trigger",
  refresh_events = {fk.AskForCardResponse,fk.AfterCardsMove,fk.PreCardUse},
  can_refresh = function(self, event, target, player, data)
    if event == fk.AskForCardResponse then
      return target == player and player:hasSkill(yin__aocai) 
    else
      return player:hasSkill(yin__aocai) 
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    local n = player:isKongcheng() and 4 or 2
    local ids = {}
    for i = 1, n, 1 do
      if i > #room.draw_pile then break end
      table.insert(ids, room.draw_pile[i])
    end
    player.room:setPlayerMark(player, "yin__aocai", ids)
  end,
}
yin__aocai:addRelatedSkill(yin__aocai_trigger)
yin__zhugeke:addSkill(yin__aocai)
yin__zhugeke:addSkill("duwu")
Fk:loadTranslationTable{
  ["yin__zhugeke"] = "诸葛恪",

  ["yin__aocai"] = "傲才",
  [":yin__aocai"] = "当你需要使用或打出一张牌时，你可以观看牌堆顶的两张牌（若你没有手牌则改为四张），若你观看的牌中有此牌，你可以使用或打出之。",
  ["#yin__aocai"] = "傲才：你可以使用或打出其中你需要的牌",

}




































































--[[local yin__shichangshi = General(extension, "yin__shichangshi", "god", 3)
local tenChangShiMapper = {
  ["yin_shichangshi__zhangrang"] = "yin_shichangshi_taoluan",
  ["yin_shichangshi__m_ex__xusheng"] = "m_ex__pojun",
  ["yin_shichangshi_luotong"] = "yin_shichangshi_qinzheng",
  ["yin_shichangshi__yin__godguojia"] = "yin__godHuishi",
  ["yin_shichangshi__yangbiao"] = "mobile__yizheng",
  ["yin_shichangshi__majun"] = "qiaosi",
  ["yin_shichangshi__godganning"] = "poxi|yin_shichangshi_jieying",
  ["yin_shichangshi__mou__huangzhong"] = "mou__liegong",
  ["yin_shichangshi__mou__wolong"] = "yin__shichangshi__huoji",
  ["yin_shichangshi__godzhaoyun"] = "longhun",
}
Fk:loadTranslationTable{
  ["yin_changshi"] = "常侍",
  ["yin_shichangshi__zhangrang"] = "张让",
  ["yin_shichangshi__m_ex__xusheng"] = "界徐盛",
  ["yin_shichangshi_luotong"] = "骆统",
  ["yin_shichangshi__yin__godguojia"] = "神郭嘉",
  ["yin_shichangshi__yangbiao"] = "杨彪",
  ["yin_shichangshi__majun"] = "马钧",
  ["yin_shichangshi__godganning"] = "神甘宁",
  ["yin_shichangshi__mou__huangzhong"] = "谋黄忠",
  ["yin_shichangshi__mou__wolong"] = "谋卧龙诸葛亮",
  ["yin_shichangshi__godzhaoyun"] = "神赵云",

  [":yin_shichangshi__zhangrang-specificSkillDesc"] = "滔乱",
  [":yin_shichangshi__m_ex__xusheng-specificSkillDesc"] = "破军",
  [":yin_shichangshi_luotong-specificSkillDesc"] = "勤政",
  [":yin_shichangshi__yin__godguojia-specificSkillDesc"] = "慧识",
  [":yin_shichangshi__yangbiao-specificSkillDesc"] = " 义争" ,
  [":yin_shichangshi__majun-specificSkillDesc"] = "巧思",
  [":yin_shichangshi__godganning-specificSkillDesc"] = "魄袭",
  [":yin_shichangshi__mou__huangzhong-specificSkillDesc"] = "烈弓",
  [":yin_shichangshi__mou__wolong-specificSkillDesc"] = "火计",
  [":yin_shichangshi__godzhaoyun-specificSkillDesc"] = "龙魂",
}
local yin_shichangshi_taoluan = fk.CreateViewAsSkill{
  name = "yin_shichangshi_taoluan",
  pattern = ".",
  prompt = "#yin_shichangshi_taoluan-prompt",
  interaction = function()
    local all_names = U.getAllCardNames("bt")
    return U.CardNameBox {
      choices = U.getViewAsCardNames(Self, "yin_shichangshi_taoluan", all_names, nil, Self:getTableMark("@$yin_shichangshi_taoluan")),
      all_choices = all_names,
      default_choice = "yin_shichangshi_taoluan"
    }
  end,
  card_filter = function(self, to_select, selected)
    return #selected == 0 and Fk.all_card_types[self.interaction.data] ~= nil
  end,
  view_as = function(self, cards)
    if #cards ~= 1 or Fk.all_card_types[self.interaction.data] == nil then return end
    local card = Fk:cloneCard(self.interaction.data)
    card:addSubcard(cards[1])
    card.skillName = self.name
    return card
  end,
  before_use = function(self, player, use)
    player.room:addTableMark(player, "@$yin_shichangshi_taoluan", use.card.trueName)
  end,
  after_use = function(self, player, use)
    local room = player.room
    local targets = table.map(room:getOtherPlayers(player, false), Util.IdMapper)
    local tos = room:askForChoosePlayers(player, targets, 1, 1, "#yin_shichangshi_taoluan-choose:::",false)
    local card = room:askForCardChosen(player, tos, "he", self.name, "#yin_shichangshi_taoluan-prey::"..tos.id)
      room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, self.name, nil, true, player.id)
      room:drawCards(tos, 1)
  end,
  enabled_at_play = function(self, player)
    return table.every(Fk:currentRoom().alive_players, function(p) return not p.dying end)
  end,
  enabled_at_response = function(self, player, response)
    if not response and Fk.currentResponsePattern and
    table.every(Fk:currentRoom().alive_players, function(p) return not p.dying end) then
      local mark = Self:getTableMark("@$yin_shichangshi_taoluan")
      for _, id in ipairs(Fk:getAllCardIds()) do
        local card = Fk:getCardById(id)
        if (card.type == Card.TypeBasic or card:isCommonTrick()) and not card.is_derived and
          Exppattern:Parse(Fk.currentResponsePattern):match(card) then
          if not table.contains(mark, card.trueName) then
            return true
          end
        end
      end
    end
  end,

  on_lose = function (self, player)
    player.room:setPlayerMark(player, "@$yin_shichangshi_taoluan", 0)
  end,
}
Fk:loadTranslationTable{
  ["yin_shichangshi_taoluan"] = "滔乱",
  [":yin_shichangshi_taoluan"] = "出牌阶段，你可以将一张牌当任意基本牌或普通锦囊牌使用,然后获得一名其他角色一张牌，然后其摸一张牌。",
  ["#yin_shichangshi_taoluan-prey"] = "滔乱：获得 %dest 一张牌",
  ["#taoluan-choose"] = "滔乱：选择一名其他角色",
  ["@$taoluan"] = "滔乱",
}
yin__shichangshi:addRelatedSkill("yin_shichangshi_taoluan")
yin__shichangshi:addRelatedSkill("m_ex__pojun")
local yin_shichangshi_qinzheng = fk.CreateTriggerSkill{
  name = "yin_shichangshi_qinzheng",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.CardUsing, fk.CardResponding},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and
      not table.every({ 2, 4, 6 }, function(num)
        return player:getMark("@" .. self.name) % num ~= 0
      end)
  end,
  on_use = function(self, event, player, target, data)
    local loopList = table.filter({ 2, 4, 6 }, function(num)
      return player:getMark("@" .. self.name) % num == 0
    end)

    local toObtain = {}
    for _, count in ipairs(loopList) do
      local cardList = "slash"
      if count == 4 then
        cardList = "analeptic"
      elseif count == 6 then
        cardList = "ex_nihilo,duel"
      end
      local randomCard = player.room:getCardsFromPileByRule(cardList)
      if #randomCard > 0 then
        table.insert(toObtain, randomCard[1])
      end
    end

    if #toObtain > 0 then
      player.room:moveCards({
        ids = toObtain,
        to = player.id,
        toArea = Card.PlayerHand,
        moveReason = fk.ReasonPrey,
        proposer = player.id,
        skillName = self.name,
      })
    end
  end,

  refresh_events = {fk.CardUsing, fk.CardResponding, fk.EventLoseSkill},
  can_refresh = function(self, event, target, player, data)
    if event == fk.EventLoseSkill then
      return target == player and data == self
    end
    return player:hasSkill(self) and target == player
  end,
  on_refresh = function(self, event, target, player, data)
    if event == fk.EventLoseSkill then
      player.room:setPlayerMark(player, "@" .. self.name, 0)
    else
      player.room:addPlayerMark(player, "@" .. self.name, 1)
    end
  end,
}
Fk:loadTranslationTable{
  ["yin_shichangshi_qinzheng"] = "勤政",
  [":yin_shichangshi_qinzheng"] = "锁定技，你每使用或打出：两张牌时，你获得一张【杀】；四张牌时，你获得一张【酒】；"..
  "六张牌时，你随机获得一张【无中生有】或【决斗】。",
  ["@yin_shichangshi_qinzheng"] = "勤政",
}
yin__shichangshi:addRelatedSkill("yin_shichangshi_qinzheng")
yin__shichangshi:addRelatedSkill("yin__godHuishi")
yin__shichangshi:addRelatedSkill("mobile__yizheng")
yin__shichangshi:addRelatedSkill("qiaosi")
local yin_shichangshi_jieying = fk.CreateTriggerSkill{
  name = "yin_shichangshi_jieying",
  mute = true,
  target_num = 1,
  prompt = "#yin_shichangshi_jieying",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = function(self, to_select, selected)
    return #selected == 0 and not Self:prohibitDiscard(Fk:getCardById(to_select))
  end,
  target_filter = function(self, to_select, selected, cards)
    local target = Fk:currentRoom():getPlayerById(to_select)
    return #selected == 0  and
    not target:isKongcheng() and (target:isMale())
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    if player.dead or target.dead or target:isKongcheng() then return end
    room:moveCardTo(target:getCardIds("h"), Card.PlayerHand, player, fk.ReasonPrey, self.name, nil, false, player.id)
    room:addPlayerMark(target, "@yin_shichangshi_jieying",1)
    end,
}
local yin_shichangshi_jieying_DrawNCards = fk.CreateTriggerSkill{
  name = "#yin_shichangshi_jieying_DrawNCards",
  events = {fk.DrawNCards},
  can_trigger = function(self, event, target, player, data)
    return player:getMark("@yin_shichangshi_jieying") > 0 
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    data.n = data.n + 1
  end,
}
local yin_shichangshi_jieying_targetmod = fk.CreateTargetModSkill{
  name = "#yin_shichangshi_jieying_targetmod",
  residue_func = function(self, player, skill, scope)
    if skill.trueName == "slash_skill" and player:getMark("@@yin_shichangshi_jieying") > 0 and scope == Player.HistoryPhase then
      return #table.filter(Fk:currentRoom().alive_players, function (p) return p:hasSkill(yin_shichangshi_jieying) end)
    end
  end,
}
local yin_shichangshi_jieying_maxcards = fk.CreateMaxCardsSkill{
  name = "#yin_shichangshi_jieying_maxcards",
  correct_func = function(self, player)
    if player:getMark("@@yin_shichangshi_jieying") > 0 then
      return #table.filter(Fk:currentRoom().alive_players, function (p) return p:hasSkill(yin_shichangshi_jieying) end)
    else
      return 0
    end
  end,
}
local yin_shichangshi_jieying_Refresh = fk.CreateTriggerSkill{
  name = "#yin_shichangshi_jieying_Refresh",
  refresh_events = { fk.AfterTurnEnd, },
  can_refresh = function(self, event, target, player, data)
    if event == fk.AfterTurnEnd then
      return
        target == player and
        table.find(
          { "@yin_shichangshi_jieying"},
          function(markName) return player:getMark(markName) ~= 0 end
        )
    end
  end,
}
yin_shichangshi_jieying:addRelatedSkill(yin_shichangshi_jieying_Refresh)
yin_shichangshi_jieying:addRelatedSkill(yin_shichangshi_jieying_DrawNCards)
yin_shichangshi_jieying:addRelatedSkill(yin_shichangshi_jieying_targetmod)
yin_shichangshi_jieying:addRelatedSkill(yin_shichangshi_jieying_maxcards)
fk:loadTranslationTable{
  ["yin_shichangshi_jieying"] = "劫营",
  [":yin_shichangshi_jieying"] = "出牌阶段限一次，获得一名其他角色所有手牌；其下个回合摸牌阶段多摸一张牌、使用【杀】的次数上限+1、手牌上限+1。",
}
yin__shichangshi:addRelatedSkill("poxi|yin_shichangshi_jieying")
yin__shichangshi:addRelatedSkill("mou__liegong")
local yin__shichangshi__huoji = fk.CreateActiveSkill{
  name = "yin__shichangshi__huoji",
  anim_type = "offensive",
  prompt = "#yin__shichangshi__huoji",
  frequency = Skill.Quest,
  card_num = 0,
  target_num = 1,
  mute = true,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected, selected_cards)
    return #selected == 0 and to_select ~= Self.id
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    room:notifySkillInvoked(player, self.name)
    player:broadcastSkillInvoke(self.name, math.random(2))
    room:damage{
      from = player,
      to = target,
      damage = 1,
      damageType = fk.FireDamage,
      skillName = self.name,
    }
    local targets = {}
    for _, p in ipairs(room:getAlivePlayers()) do
      if p ~= player and p ~= target and p.kingdom == target.kingdom then
        table.insert(targets, p)
      end
    end
    for _, p in ipairs(targets) do
      if not p.dead then
        room:damage{
          from = player,
          to = p,
          damage = 1,
          damageType = fk.FireDamage,
          skillName = self.name,
        }
      end
    end
  end,
}
Fk:loadTranslationTable{
  ["yin__shichangshi__huoji"] = "火计",
  [":yin__shichangshi__huoji"] = "，出牌阶段限一次，你可以选择一名其他角色，对其及其同势力的其他角色各造成1点火焰伤害。",
}
yin__shichangshi:addRelatedSkill("yin__shichangshi__huoji")
yin__shichangshi:addRelatedSkill("longhun")
local yin__danggu = fk.CreateTriggerSkill{
  name = "yin__danggu",
  frequency = Skill.Compulsory,
  anim_type = "negative",
  events = {fk.GameStart, fk.TurnStart, fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
      return player:hasSkill(self)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room

    ---@param room Room
    ---@param player ServerPlayer
    ---@param generals string[]
    local doJieDang = function(room, player, generals)
      if type(generals) ~= "table" or #generals < 2 then
        return
      end

      generals = table.simpleClone(generals)

      local mainGeneral
      local deputyGeneral
      if #generals < 3 then
        mainGeneral = generals[1]
        deputyGeneral = generals[2]
      else
        mainGeneral = table.random(generals)
        table.removeOne(generals, mainGeneral)
        local deputyGenerals = table.random(generals, 7)


        local result = room:askForCustomDialog(
          player, "jiedang",
          "packages/mobile/qml/JieDangBox.qml",
          { mainGeneral, deputyGenerals }
        )

        if result ~= "" then
          deputyGeneral = json.decode(result).general
        else
          deputyGeneral = table.random(deputyGenerals)
        end
      end

      player.tag['jiedang_before_generals'] = { player.general, player.deputyGeneral }

      player.tag['changshi_cards'] = generals
      room:setPlayerMark(player, "@&changshiCards", #generals > 0 and generals or 0)

      room:changeHero(player, mainGeneral, true, false, false, false)
      room:changeHero(player, deputyGeneral, true, true, false, false)
      room:handleAddLoseSkills(player, tenChangShiMapper[mainGeneral] .. "|" .. tenChangShiMapper[deputyGeneral], nil, false)
    end
    if event == fk.GameStart then
      local tenChangShis = {}
      for changShi, _ in pairs(tenChangShiMapper) do
        table.insert(tenChangShis, changShi)
      end
      room:setPlayerMark(player, "@&changshiCards", tenChangShis)

      doJieDang(room, player, tenChangShis)
    else 
      doJieDang(room, player, player.tag['changshi_cards'])
      player:drawCards(1, self.name)
    end
  end,

  refresh_events = { fk.BeforeGameOverJudge, fk.GameFinished, fk.AfterPropertyChange },
  can_refresh = function(self, event, target, player, data)
    if not player.tag['jiedang_before_generals'] then
      return false
    end
    
    if event == fk.AfterPropertyChange then
      return target == player and data.results and (data.results.generalChange or data.results.deputyChange)
    else
      return event == fk.GameFinished or target == player
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    if event == fk.AfterPropertyChange then
      if data.results.generalChange then
        local beforeGeneral = data.results.generalChange[1]
        if tenChangShiMapper[beforeGeneral] then
          room:handleAddLoseSkills(player, "-" .. tenChangShiMapper[beforeGeneral], nil, false)
        end

        if not tenChangShiMapper[player.general] then
          player.tag['jiedang_before_generals'][1] = player.general
        end
      end

      if data.results.deputyChange then
        local beforeGeneral = data.results.deputyChange[1]
        if tenChangShiMapper[beforeGeneral] then
          room:handleAddLoseSkills(player, "-" .. tenChangShiMapper[beforeGeneral], nil, false)
        end

        if not tenChangShiMapper[player.deputyGeneral] then
          player.tag['jiedang_before_generals'][2] = player.deputyGeneral
        end
      end
    else
      local generals = player.tag['jiedang_before_generals']

      local hasDangGu = player:hasSkill(self, true, true)
      local hasMoWang = player:hasSkill("mowang", true, true)

      if #generals > 1 then
        if event == fk.GameFinished then
          room:setPlayerProperty(player, "deputyGeneral", generals[2])
        else
          room:changeHero(player, generals[2], false, true, false, false)
        end
      end
      if generals[1] ~= "" then
        if event == fk.GameFinished then
          room:setPlayerProperty(player, "general", generals[1])
        else
          room:changeHero(player, generals[1], false, false, false, false)
        end
      end

      if event == fk.GameFinished then
        return false
      end

      local toObtain = {}
      if hasDangGu and not player:hasSkill(self) then
        table.insert(toObtain, self.name)
      end
      if hasMoWang and not player:hasSkill("mowang") then
        table.insert(toObtain, "mowang")
      end

      if #toObtain > 0 then
        room:handleAddLoseSkills(player, table.concat(toObtain, "|"), nil, false)
      end
    end
  end,
}

  local yin__mowang = fk.CreateTriggerSkill{
    name = "yin__mowang",
    frequency = Skill.Compulsory,
    anim_type = "negative",
    events = {fk.BeforeGameOverJudge},
    can_trigger = function(self, event, target, player, data)
        return
          target == player and
          player:hasSkill(self, false, true) and
          player:hasSkill("danggu", true, true) and
          type(player.tag["changshi_cards"]) == "table" and
          #player.tag["changshi_cards"] > 0 and
          player.maxHp > 0
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
        player._splayer:setDied(false)
        room:recover({
          who = player,
          num = player.maxHp - player.hp,
          recoverBy = player,
          skillName = self.name,
        })
        player:drawCards(3, self.name)
        table.removeOne(generals, mainGeneral)
        table.removeOne(generals, deputyGeneral)
    end,
  }
yin__shichangshi:addSkill(danggu)
yin__shichangshi:addSkill(mowang)
yin__shichangshi:addSkill("mou__kanpo")
yin__shichangshi:addSkill("yin__limitedHuishi")
yin__shichangshi:addSkill("yin__tianyi")
yin__shichangshi:addSkill("zhaohan")
yin__shichangshi:addSkill("rangjie")
yin__shichangshi:addSkill("jingxie")
yin__shichangshi:addSkill("juejing")
Fk:loadTranslationTable{
  ["yin__shichangshi"] = "十常侍",
  ["danggu"] = "党锢",
  [":danggu"] = "锁定技，游戏开始时，你获得十张不同的“常侍”牌，然后你选择两张“常侍”牌；你的回合开始或结束时，你可以重新选择两张“常侍”牌。",
  ["@&changshiCards"] = "常侍",
  ["yin__mowang"] = "殁亡",
  [":yin__mowang"] = "锁定技，当你即将死亡时，若你拥有技能“党锢”且你仍有的“常侍”牌，则改为失去你正在使用的“常侍”牌，并重新选择两张“常侍”牌。",
}

]]







return extension